/*
* @Author: obsidian
* @Date:   2016-03-10 10:17:33
* @Last Modified by:   obsidian
* @Last Modified time: 2016-05-21 20:54:21
*/
#include "menu_mesure.h"
#include "../lcd_global.h"
#include "../lcd.h"
#include "control/GPSpath/GPSpath.h"
#include "control/car.h"
#include "module/camera/camera.h"
#include "module/ledboard/ledboard.h"
#include "module/GPS/gps.h"

//enter  exec input back
void  menu_mesure_init(void *parg);
void  menu_ledboard_close(void *parg){ledboard.status = 0;}
void  menu_ledboard_open(void *parg){ledboard.status = 1;}

struct Item mesure_i[MAX_ITEM_NUM] = 
{
    {.ctx = "clsled",      .id = 1, .ctx_len = 6, .flag = FILE, .value_type = NONE, .p_value = (void *)&gpspath.pre,          .func_enter =   nop, menu_ledboard_close,nop,nop},
    {.ctx = "openled",      .id = 2, .ctx_len = 7, .flag = FILE, .value_type = NONE, .p_value = (void *)&gpspath.pre,          .func_enter =   nop, menu_ledboard_open,nop,nop},
 
		{.ctx = "rangle",      .id = 3, .ctx_len = 6, .flag = FILE, .value_type = FLOAT, .p_value = (void *)&car_para[0].r_start_angle,          .func_enter =   nop, input,nop,nop},
	{.ctx = "rsty",      .id = 4, .ctx_len = 4, .flag = FILE, .value_type = FLOAT, .p_value = (void *)&car_para[0].r_start_y,          .func_enter =   nop, input,nop,nop},
		{.ctx = "langle",      .id = 5, .ctx_len = 6, .flag = FILE, .value_type = FLOAT, .p_value = (void *)&car_para[0].l_start_angle,          .func_enter =   nop, input,nop,nop},
	{.ctx = "6.lsty",      .id = 6, .ctx_len = 6, .flag = FILE, .value_type = FLOAT, .p_value = (void *)&car_para[0].l_start_y,          .func_enter =   nop, input,nop,nop},
 
	{.ctx = "direction",      .id = 7, .ctx_len = 9, .flag = FILE, .value_type = INTEGER, .p_value = (void *)&gps.direction,          .func_enter =   nop, input,nop,nop,.realtime = 1},
    {.ctx = "ledstus",      .id = 8,   .ctx_len = 7,  .flag = FILE, .realtime = 1, .value_type = INTEGER, .p_value = (void *)&ledboard.status,      .func_enter = nop, nop,  nop,    nop},
        {.ctx = "9.restart",     .id = 9, .ctx_len = 7,  .flag = FILE,   .value_type = NONE, .p_value = 0, .func_enter = nop, .func_exec = restart, .func_input_callback = nop, .func_back = nop},
    {.ctx = "angle",      .id = 10,   .ctx_len = 5,  .flag = FILE, .realtime = 1, .value_type = FLOAT, .p_value = (void *)&gps.angle,              .func_enter = nop, nop,  nop,    nop},    

};
struct Node mesure_n = 
{
    // .itemnum            =   sizeof(mesure_i) / sizeof(mesure_i[0]),
    // .page_num           =   sizeof(mesure_i) / sizeof(mesure_i[0]) / PAGE_SIZE,
    .page_index         =   0,  
    .node_id            =   6,  
    .p_item             =   mesure_i,
    .position           =   {0, 0},
    .parent             =   &root_n,
    .child              =   {0},
    .init               =   menu_mesure_init,
};
void  menu_mesure_init(void *parg)
{
    unsigned char i = 0;
    for(i = 0;i < MAX_ITEM_NUM;i ++)
    {
        if(mesure_i[i].ctx[0] == 0){break;}
        mesure_n.itemnum ++;
    }
    mesure_n.page_num = mesure_n.itemnum / PAGE_SIZE;

}
